package com.bwie.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bwie.pojo.TbProdInfo;
import com.bwie.service.TbProdInfoService;
import com.bwie.mapper.TbProdInfoMapper;
import com.bwie.utils.Result;
import com.bwie.vo.PageInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author Lenovo
* @description 针对表【tb_prod_info(商品详情表)】的数据库操作Service实现
* @createDate 2025-05-29 19:17:53
*/
@Service
public class TbProdInfoServiceImpl extends ServiceImpl<TbProdInfoMapper, TbProdInfo>
    implements TbProdInfoService{

    @Autowired
    TbProdInfoMapper tbProdInfoMapper;

    @Override
    public Result getProdInfoPage(PageInfoVo pageInfoVo) {
        Page<TbProdInfo> page = new Page<>(pageInfoVo.getPageNum(), pageInfoVo.getPageSize());

        LambdaQueryWrapper<TbProdInfo> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(TbProdInfo::getProdId,pageInfoVo.getTypeId());
        wrapper.orderByDesc(TbProdInfo::getInfoId);

//        Page<TbProdInfo> tbProdInfoPage = tbProdInfoMapper.selectPage(page, wrapper);
        Page<TbProdInfo> tbProdInfoPage = tbProdInfoMapper.getProdInfoPage(page, pageInfoVo.getTypeId());

        for (TbProdInfo record : tbProdInfoPage.getRecords()) {
            record.setBuyNum(0);
        }

        return Result.ok().setData(tbProdInfoPage);
    }
}




